package com.lighting.lightingservice.controller;

import com.lighting.lightingservice.dto.Image;
import com.lighting.lightingservice.dto.Video;
import com.lighting.lightingservice.service.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ImageController {

    @Autowired
    private ImageService imageService;

    @RequestMapping("/image")
    @ResponseBody
    @CrossOrigin
    List<Image> allImages() {

        return  imageService.getImageByDB();
    }

    @RequestMapping("/imageInsert")
    @ResponseBody
    @CrossOrigin
    void insertImage(String name, String url){
        imageService.insertImage(name, url);
    }

    @RequestMapping("/imageDel")
    @ResponseBody
    @CrossOrigin
    void deleteImage(String name){
        imageService.deleteImage(name);
    }
}
